package com.me.libgdx_test;

import java.util.Random;

//Potion Restore: health, mana
//Potion Use: 10% chance to give 1 exp, gives 5 gold per lvl, nxt hit +30% dmg
//Potion Pickup: converts mana potion to health potion
public class ClassPlayerPotionMod {
	float health_potion_mod; 
	float mana_potion_mod; 
	int start_health_potion;
	int start_mana_potion;
	String potion_use;
	String potion_pickup;
	Random random = new Random(System.currentTimeMillis());
	ClassPlayerPotionMod(float health_potion_mod, float mana_potion_mod, int start_health_potion, int start_mana_potion, String potion_use, String potion_pickup){
		this.health_potion_mod = health_potion_mod;
		this.mana_potion_mod = mana_potion_mod;
		this.potion_use = potion_use;
		this.potion_pickup = potion_pickup;
		this.start_health_potion = start_health_potion;
		this.start_mana_potion = start_mana_potion;
	}
	public void potion_pickup(ClassCharacterPlayer player,boolean health_potion){
		if(potion_pickup.equals("mana=>health") && !health_potion){
			player.set_player_variable("mana_potions", player.get_player_variable("mana_potions")-1);
			player.set_player_variable("health_potions", player.get_player_variable("health_potions")+1);
		}
		if(potion_pickup.equals("health=>mana") && health_potion){
			player.set_player_variable("mana_potions", player.get_player_variable("mana_potions")+1);
			player.set_player_variable("health_potions", player.get_player_variable("health_potions")-1);
		}
	}
	public void potion_use(ClassCharacterPlayer player, boolean health_potion){
		player.add_god_action("potions");
		if(potion_use.equals("both_potions")){
			if(health_potion){
				player.set_player_variable("current_mana", 
						(int)(player.get_player_variable("current_mana") + ((float)player.get_player_variable("max_mana") * 
								player.get_class_mods().playerPotionMod.mana_potion_mod)));
			}else{
				player.set_player_variable("current_health", 
						(int)(player.get_player_variable("current_health") + ((float)player.get_max_health() * 
								player.get_class_mods().playerPotionMod.health_potion_mod)));
			}
		}
		if(potion_use.equals("10%_1_exp")){
			if(random.nextInt(10)>8){
				player.add_exp(player.get_player_variable("level"));
			}
		}
		if(potion_use.equals("5_gold_lvl")){
			player.set_player_variable("gold", player.get_player_variable("gold") + player.get_player_variable("level")*5);
		}
		if(potion_use.equals("nxt_hit_30%")){
			player.attack_bonus+=.3;
		}
	}
}
